#define _CRT_SECURE_NO_WARNINGS 1
#include"Sequence List.h"
#include"SingelList.h"
#include"Stack.h"
#include"Queue.h"
#include"DoubleListWithHead.h"
#include"Heap.h"

void testSeqList()
{
	SL SeqList;
	SLinit(&SeqList);
	SLInsert(&SeqList, 1, 1);
	SLInsert(&SeqList, 1, 5);
	SLInsert(&SeqList, 1, 8);
	SLInsert(&SeqList, 1, 3);
	SLInsert(&SeqList, 1, 4);
	SLprint(&SeqList);
	SLDelByData(&SeqList, 8);
	SLPushFront(&SeqList, 8);
	SLDelByDes(&SeqList, 4);
	SLInsert(&SeqList, 2, 5);
	SLprint(&SeqList);
	SLPopFront(&SeqList);
	SLPopBack(&SeqList);
	SLPushBack(&SeqList, 0);
	SLprint(&SeqList);
	SLDestory(&SeqList);
}

void testSingelList()
{
	SLT* phead = NULL;
	SLTpushback(&phead, 1);
	SLTpushback(&phead, 2);
	SLTpushback(&phead, 3);
	SLTpushback(&phead, 4);
	SLTpushfront(&phead, 0);
	SLTpopfront(&phead);
	SLTpopback(&phead);
	SLTprint(phead);
	SLTInsertFront(&phead, 2, 0);
	SLTInsertAfter(&phead, 0, 1);
	SLTEraseFront(&phead, 4);
	SLTEraseAfter(&phead, 2);
	SLTprint(phead);
	SLDestory(&phead);
}

void testStack()
{
	Stack st;
	StackInit(&st);
	StackPush(&st, 1);
	StackPush(&st, 2);
	StackPush(&st, 3);
	StackPush(&st, 4);
	StackPush(&st, 5);
	printf("%d\n", StackSize(&st));
	while (!StackEmpty(&st))
	{
		printf("%d ", StackTop(&st));
		StackPop(&st);
	}
	StackDestory(&st);
}

void testQueue()
{
	Queue q;
	QueueInit(&q);
	QueuePush(&q, 1);
	QueuePush(&q, 2);
	QueuePush(&q, 3);
	QueuePush(&q, 4);
	QueuePush(&q, 5);
	printf("%d\n", QueueFront(&q));
	printf("%d\n", QueueBack(&q));
	printf("%d\n", QueueSize(&q));
	while (!QueueEmpty(&q))
	{
		printf("%d ", QueueFront(&q));
		QueuePop(&q);
	}
}

void testDoubleListWithHead()
{
	DLH* phead = DLHInit();
	DLHPushBack(phead, 4);
	DLHPushBack(phead, 5);
	DLHPushBack(phead, 6);
	DLHPushFront(phead, 3);
	DLHPushFront(phead, 2);
	DLHPushFront(phead, 1);
	DLHPrint(phead);
	DLHErase(DLHFind(phead, 2));
	DLHErase(DLHFind(phead, 4));
	DLHErase(DLHFind(phead, 6));
	DLHPopFront(phead);
	DLHPopBack(phead);
	DLHInsertFront(DLHFind(phead, 3), 2);
	DLHInsertBack(DLHFind(phead, 3), 4);
	while (!DLHEmpty(phead))
	{
		DLHPopBack(phead);
	}
	DLHDestory(phead);
}

void testHeap()
{
	Heap h;
	HeapInit(&h);
	HeapPush(&h, 5);
	HeapPush(&h, 54);
	HeapPush(&h, 15);
	HeapPush(&h, 75);
	HeapPush(&h, 2);
	HeapPush(&h, 6);
	HeapPush(&h, 21);
	while (!HeapEmpty(&h))
	{
		printf("%d ", HeapTop(&h));
		HeapPop(&h);
	}
	HeapDestory(&h);
}

int main()
{
	//testSeqList();
	//testSingelList();
	//testStack();
	//testQueue();
	//testDoubleListWithHead();
	//testHeap();
	return 0;
}